package com.lw.controller;

import com.lw.service.imp.ContentServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author LW
 * @2020/8/25 11:16
 */
@RestController
public class ContentController {

    @Autowired
    ContentServiceImp contentServiceImp;


    //爬取数据
    @GetMapping("/parse/{keyword}")
    public Boolean parseContent(@PathVariable("keyword") String keyword) throws Exception {
        return contentServiceImp.parseContent(keyword);

    }

    //搜索
    @GetMapping("/search/{keyword}/{pageNo}/{pageSize}")
    public List<Map<String, Object>>  searchPage(@PathVariable("keyword") String keyword,
                                                 @PathVariable("pageNo") int pageNo,
                                                 @PathVariable("pageSize") int pageSize) throws Exception {

        return contentServiceImp.searchPage(keyword, pageNo, pageSize);

    }

    //搜索================高亮
    @GetMapping("/searchHighlight/{keyword}/{pageNo}/{pageSize}")
    public List<Map<String, Object>>  searchHighlightPage(@PathVariable("keyword") String keyword,
                                                 @PathVariable("pageNo") int pageNo,
                                                 @PathVariable("pageSize") int pageSize) throws Exception {

        return contentServiceImp.searchHighlightPage(keyword, pageNo, pageSize);

    }






}
